<html>
<head>
	<meta charset='utf-8' />
	<title>便民信息</title>
	<meta http-equiv="keywords" content="求职,招聘,房屋,出租,出售,求租,求购,宠物,二手,二手车,二手物品,旧货,寻物,寻人,出兑,外兑"> 
	<meta http-equiv="description" content="便民信息网,房屋租售,宠物交易,二手物品,二手车辆,寻物寻人,出兑信息">  
	<meta name="description" content="便民信息网,房屋租售,宠物交易,二手物品,二手车辆,寻物寻人,出兑信息"/>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<style>
		@media screen and (max-width:450px){
			#nav_bottom{width:98%;margin:0 auto}
			#content{width:98%;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		@media screen and (min-width:450px){
			#nav_bottom{width:450px;margin:0 auto}
			#content{width:450px;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		.Back_Index{cursor:pointer;}
	</style>
</head>
<body style='padding:0;margin:0;background:#eee'>
<!-- 1 Content容器 -->
<div id='Content'>



	<!-- 2 顶部广容器-->
	<div style='height:70px;border:1px solid #369;display:flex;text-align:center' id='Advert_Top'>

	</div><!-- 2 顶部广容器结束-->





	<!-- 4 detail页面区-->
	<div id='Detail' style='border:1px solid #ccc;margin:10px 0;word-break:break-all;padding:10px;'>

		<!--标题-->
		<div id='Detail_Title' style='margin:10px 0;text-align:center;font:normal bold 18px normal;color:#555'>
			信息不存在或被封禁！
		</div>


		<!--联系人和联系方式-->
		<div style='margin:10px 0;text-align:center;font-size:12px'>
			发布时间：<span id='Detail_Date'></span>
		</div>


		<!--服务类型与地域-->
		<div style='margin:10px 0;display:flex'>
			<div style='width:80px'>类　型：</div>
			<div style='flex:1' id='Detail_Service'></div>
		</div>
			
		<!--内容-->
		<div style='margin:5px 0;display:flex'>
			<div style='width:80px'>详　情：</div>
			<div style='flex:1' id='Detail_Content'></div>
		</div>


		<!--联系人和联系方式-->
		<div style='margin:10px 0;display:flex'>
			<div style='width:80px'>电　话：</div>
			<div style='flex:1' id='Detail_Phone'></div>
		</div>

		<div style='margin:10px 0;display:flex'>
			<div style='width:80px'>联系人：</div>
			<div style='flex:1' id='Detail_Contacts'></div>
		</div>


		<div style='margin:10px 0;text-align:center;color:red'>
			<h2 id='expire'></h2>
		</div>

		<!--图片区-->
		<img id='Detail_Img0' src='' style='width:100%;margin:20px 0;display:none' />
		<img id='Detail_Img1' src='' style='width:100%;margin:20px 0;display:none' />
		<img id='Detail_Img2' src='' style='width:100%;margin:20px 0;display:none' />
		<img id='Detail_Img3' src='' style='width:100%;margin:20px 0;display:none' />
		<img id='Detail_Img4' src='' style='width:100%;margin:20px 0;display:none' />


		<div style='text-align:center'>
			<button class='Back_Index'>返回</button>
		</div>

	</div><!-- 4 detail页面区结束-->
	






	<!--底部广告
	<div style='height:80px;border:1px solid red;margin-bottom:45px' id='Advert_Bottom'>
		底部广告区
	</div>-->

</div><!-- 1 Content容器结束 -->





<!--底部导航容器-->
<div id='Nav_Bottom' style='position:fixed;bottom:0;width:100%;height:45px'>

</div><!--底部导航容器结束-->


</body>
</html>
<script src='./Public/jquery.js'></script>
<script src='./Public/fun.js'></script>
<script>

	//加载底部导航栏
	Load_NavBottom('before');

	$(function(){
		
		Set_Title();	//设置页面title
		
		Set_Advert_Top();	//临时设置顶部广告

		var detail_sess_str = 'sessionStorage.Detail_'+GetUrlParm('iid');
		if(eval(detail_sess_str)){
			var stampt = parseInt(sessionStorage.Detail_stampt);
			if(stampt+5000 > new Date().getTime()){		//没过期 
				console.log('sess_get');
				Parse_Detail_Res(unescape(eval(detail_sess_str)),stampt);
			}else{	//sess过期了
				LoadDetail();
			}
			//alert(eval(detail_sess_str));
			//alert(sessionStorage.Detail_stampt);
		}else{
			LoadDetail();
		}
		//sessionStorage.Detail_stampt


		//返回时判断是index页来的还是me页来的
		$('.Back_Index').click(function(){
			if(GetUrlParm('type')=='me'){
				location.href='me.html';
			}else{
				location.href='index.html';
			}
		});


	});


	function LoadDetail(){

		sessionStorage.Detail_stampt = new Date().getTime();
		//加载当前详情
		var type = 'Get_Detail_Info';
		$.ajax({
			url:'Cache/Detail/'+GetUrlParm('iid'),
			async:false,
			success(res,a,b){
				//console.log(res)
				console.log('cache_get');
				var stampt = new Date(b.getResponseHeader('Date')).getTime();
				eval('sessionStorage.Detail_'+GetUrlParm('iid') + "='"+escape(res)+"'");
				Parse_Detail_Res(res,stampt);	//解析detail详情的res结果
			},
			error(){
				Token(type,function(token){
					$.ajax({
						url:url,
						async:false,
						type:'post',
						data:{
							token:token,
							type:type,
							iid:GetUrlParm('iid'),
						},
						success(res,a,b){
							console.log('after_get');
							var stampt = new Date(b.getResponseHeader('Date')).getTime();
							eval('sessionStorage.Detail_'+GetUrlParm('iid') + "='"+escape(res)+"'");
							Parse_Detail_Res(res,stampt);	//解析detail详情的res结果
						}
					});
				});
			}
		});
	}




	
/*
	["1023","1","8","38da5","dcd169d618d4991b5abb","0b60328c9f71b41","2222222222",null,"xian","1","0","2","1527517881"]
	[0]info_id,
	[1]info_uid 
	[2]info_service,
	[3]info_title,
	[4]info_content,
	[5]info_contacts,
	[6]info_phone,
	[7]info_imgs,
	[8]info_city_xian,
	[9]info_stat,
	[10]info_stat_explain,
	[11]info_auto_issue,
	[12]info_issue_time
*/		
	//解析detail详情的res结果
	function Parse_Detail_Res(res,b){
		if(!/^\[.+\]$/.test(res)){
			return;
		}
		//console.log(res)
		//sess缓存数据及时间
		//alert(b);
		var t = new Date(parseInt(b));
		var data = JSON.parse(res);
		//判断只显示正常和过期的信息
		if(data[9] != 1 && data[9] != 2){
			return;
		}else{
			if(data[9] !=1){
				var expire_str = '该信息已失效!!!';
			}
		}
		var server_time = t.getTime();	//当前服务器时间戳
		var issue_time = parseInt(data[11])*1000;	//信息发布时间戳

		//根据是否自动发布，显示发布时间
		if(data[10] == 1){
			var expire = server_time-86400000*30;
			if(expire > issue_time){ //超过30天(过期),显示发布时间
				var t2 = StampToYmd(issue_time);
				$('#Detail_Date').html(t2);	
			}else{	//未过期，显示当前服务器时间
				var t2 = StampToYmd(server_time);
				$('#Detail_Date').html(t2);
			}

		}else{	//不是自动发布，则显示发布时间
			var t2 = StampToYmd(issue_time);
			$('#Detail_Date').html(t2);
		}


		//根据服务类型显示服务名
		GetServiceList(function(){
			var service_type=JSON.parse(sessionStorage.service_type);
			for(var i=0;i<service_type.length;i++){
				//alert(data.info_service+'--'+service_type[i][0]);
				if(data[2] == service_type[i][0]){
					var service_name = service_type[i][1];
				}
			}
			$('#Detail_Service').html(service_name);
		});
		$('#Detail_Title').html(data[3]);
		$('#Detail_Content').html(data[4]);
		$('#Detail_Phone').html(data[6]);
		$('#Detail_Contacts').html(data[5]);
		if(data[9] !=1){
			$('#expire').text(expire_str);
		}
		if(data[7]){
			var imgs = JSON.parse(data[7]);
			for(var i in imgs){
				if(i > 4){
					continue;
				}
				$("#Detail_Img"+i).attr('src',imgs[i]).show();
			}
		}
	}
</script>












